require('../../../assets/css/main.css')
import 'assets/js/wii_entry';
import 'assets/js/common' ;
//	import 'assets/js/share';
import 'assets/js/mengban'
import {Utils} from 'wmu2';
import Vue from 'vue'

new Vue({
    el:"#app",
    data() {
    return {
      isHandcircle:false,
      shake:{
        isShake: false,
        url: '',
        params:{
          act_id: ''
        },
        callback: function(res){
          console.log(res);
        }
      }
    }
  },
  created() {
    this.handYaoActive()
  },
  watch: {

  },
  computed: {
     
        
  },
   beforeMount: function() { 
   	
      
   },
  mounted() {
	  $('body').css('display','block');
	  GLOBAL.ajaxRequesting = false;  //ajax请求状态 true=ajax请求中 false=未发生请求
      let redRing=$('.red-ring');
      let redRingAngle=0;
       setInterval(()=>{
        redRingAngle =redRingAngle+22.5;
        redRing.animate({'rotate': redRingAngle+'deg'}, 0);
    },300);

   var area = document.getElementById('J_Scroll');
   
    if (area != null) {
        var con1 = document.getElementById('J_ScrollTip1');
        var con2 = document.getElementById('J_ScrollTip2');
        var speed = 50;
        area.scrollTop = 0;
        if ($("#J_ScrollTip1").find("li").length >= 1) {
            con2.innerHTML = con1.innerHTML;
            area.style.height = "0.68rem";
            var myScroll = setInterval(()=>{
            	
            	 if (area.scrollTop >= con1.scrollHeight) {
            area.scrollTop = 0;
        } else {
            area.scrollTop++;
        }
            	
            }, speed);
        }
    };
     var feel = {
            NAMEERROR: "请输入正确的姓名",
            PHONEERROR: "请输入正确的手机号",
            ISNEWFIELD: '请输入正确的'
        };

        isShowNewField();
//        是否显示新字段
        function isShowNewField() {
            var NewField = $('#J_NewField');
            NewField.hide();
            if ($CONFIG.newField.isNewField) {
                NewField.show();
                $('.first-open').css('height', '17.8rem')
            }
        }


        $('#submitBtn').bind("touchstart", function (event) {
        	if(GLOBAL.ajaxRequesting){
        		return false ;
        	}
            $("#J_SuccessForm").submit();
        });
        $("#J_SuccessForm").submit(function () {
            var userName = $("#userName").val();
            var phone = $("#phone").val();
            var newFieldVal = $('#newField').val();


            var phoneReg = /^1[34578]\d{9}$/;
            if (userName.length <= 1 || GLOBAL.checkNull(userName)) {
                GLOBAL.pop(feel.NAMEERROR);
                return false;
            }
            if (GLOBAL.checkNull(phone) || !phoneReg.test(phone)) {
                GLOBAL.pop(feel.PHONEERROR);
                return false;
            }

            if (!newFieldVal && $CONFIG.newField.isNewFieldVerify) {
                GLOBAL.pop(feel.ISNEWFIELD + $("#new_field_name").text());
                return false;
            }
            
            GLOBAL.ajaxRequesting = true;
            
            $.ajax({
                url:$CONFIG.submit_url,
                type: 'post',
                dataType: 'json',
                data: {
                    id: actId,
                    user_name: userName,
                    phone: phone,
                    new_field: newFieldVal
                },
                success: function (data) {
                    // ajax 成功
                    if (data.ret != 0) {
                        GLOBAL.pop('提交信息失败！');
                        return;
                    }
                    setTimeout(function () {
                        window.location.href = data.data.jump_url ;
                    }, 500);
                    GLOBAL.ajaxRequesting = false;
                },
                error: function () {
                    GLOBAL.pop('提交信息失败！');
                    GLOBAL.ajaxRequesting = false;
                }
                
            });

            return false;
        })
        
  },
  methods: {
	handYaoActive(){     // 摇动的函数
		setTimeout(()=>{
			setInterval(()=>{
				this.isHandcircle ? this.isHandcircle = false : this.isHandcircle = true;
			},600)
		},200)
  }
   
 }
})

   